<?php
namespace app\common\model;

use Predis\Client;

/**
 * redis模型
 *
 * Class Redis
 * @package app\common\model
 */
class Redis
{
    private static $_instance;

    private function __construct()
    {
    }

    /**
     * redis实例
     *
     * @return Redis|Client
     */
    public static function instance()
    {
        if (!(self::$_instance instanceof Redis)) {
            self::$_instance = new Client(
                [
                    'host' => Config::get('host', 'redis'),
                    'port' => Config::get('port', 'redis'),
                ]
            );
        }
        return self::$_instance;
    }

    private function __clone()
    {
    }
}